//
//  EmoticonsLayout.swift
//  emoticon模块代码
//
//  Created by rong on 15/7/8.
//  Copyright © 2015年 rong. All rights reserved.
//

import UIKit

class EmoticonsLayout: UICollectionViewFlowLayout {
    
    //这个函数在  collectionView 的大小设置完成后，准备布局之前会调用一次
    override func prepareLayout() {
        super.prepareLayout()
        
        print(__FUNCTION__)
        
        //设置定死了，一行是 7个表情
        let s = collectionView!.bounds.width / 7
        itemSize = CGSizeMake(s, s)
        minimumInteritemSpacing = 0
        minimumLineSpacing = 0
        
        scrollDirection = UICollectionViewScrollDirection.Horizontal
        let margin = (collectionView!.bounds.height - 3*s) * 0.5
        sectionInset = UIEdgeInsets(top: margin, left: 0, bottom: margin, right: 0)
    }
}
